package com.haipumi.actions;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.haipumi.beans.JsonModel;
import com.haipumi.beans.haipumi_product;
import com.haipumi.utils.CommonData;
import com.opensymphony.xwork2.ActionSupport;

public class GoodsAction extends ActionSupport{

	private static final long serialVersionUID = -8289947299319394784L;
	private JsonModel jm;
	private HttpServletRequest request=ServletActionContext.getRequest();
	private String op;
	
	public JsonModel getJm() {
		return jm;
	}

	public void setJm(JsonModel jm) {
		this.jm = jm;
	}

	public void setOp(String op) {
		this.op = op;
	}
	
	@Override
	public String execute() {
		if(op!=null){
			if("findAll".equals(op)){
				findAllOp( );
			}
		}
		return "success";
	}

	private void findAllOp() {
		jm=new JsonModel();
		List<haipumi_product> list=(List<haipumi_product>) request.getSession().getServletContext().getAttribute(CommonData.APPLICATIONPRODUCTKEY);
		jm.setCode(1);
		jm.setObj(list);
	}

}
